#include<bits/stdc++.h>
using namespace std;
int main()
{
//	freopen("D:\\desktop\\fifth1.in", "r", stdin);
	long long t;
	cin>>t;
	while(t--)
	{
		long long n, m, k;
		cin>>n>>k>>m;
		vector<long long> a(n);
		for(long long i = 1;i <= n;i++)
			cin>>a[i-1];
		unordered_map<long long, long long> mp;
		for(long long i = 1;i <= n;i++)
			mp[a[i-1]%m]++;
		long long flag = 0;
		for(auto i = mp.begin();i != mp.end();i++)
			if(i->second >= k)
				flag = 1;
		if(flag)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

